<template>
  <div class="container">
    <div class="showCont" v-if="!showTimeOut && showCont">
      <div class="orderMain">
        <div
          @click="detaiFn(item)"
          class="orderItem"
          :key="index"
          v-for="(item, index) in orderArr"
        >
          <div class="itemTime">2024-07-11 投递过此岗位</div>
          <div class="itemHead">
            <div class="headName">
              <div class="orderNum">前端开发工程师</div>
              <div class="quckTag">急聘</div>
            </div>
            <div class="headMoney">15~30k</div>
          </div>
          <div class="tagCont">
            <div class="tagItem">经验不限</div>
            <div class="userNum_">·</div>
            <div class="tagItem">本科</div>
            <div class="userNum_">·</div>
            <div class="tagItem">13薪</div>
          </div>
          <div class="formUnder">
            <div class="userInfo">
              <div class="userImg" v-if="item.enterprise_apply">
                <img :src="item.enterprise_apply.enterprise_logo + ossSrc" />
              </div>
              <div class="suerInfoMain noFlex">
                <div class="userNameBox">
                  <div class="userName">四川省本地鸟科技有限公司</div>
                  <div class="relTag">已认证</div>
                </div>
                <div class="compDes">
                  <div class="tagItem">成都</div>
                  <div class="userNum_">·</div>
                  <div class="tagItem">0-20人</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <noData v-if="orderArr.length == 0"></noData>
    </div>
    <div class="backBtn" @click="backFn">返回</div>
    <load v-if="!showCont"></load>
    <getTimeOut v-if="showTimeOut"></getTimeOut>
  </div>
</template>
<script>
import { positionDeliver } from "@/http/api";
import noData from "@/components/public/noData.vue";
import load from "@/components/public/load.vue";
import getTimeOut from "@/components/public/getTimeOut.vue";
export default {
  components: { noData, load, getTimeOut },
  name: "",
  data() {
    return {
      showTimeOut: false,
      showCont: false,

      orderArr: [],
      page: 1,
      per_page: 10,
      last_page: 0,
      getting: false,
    };
  },
  props: {},
  setup() {},
  methods: {
    backFn() {
      this.$router.back();
    },
    detaiFn(item) {
      this.$router.push({
        path: "/workDetail",
        query: { id: item.enterprise_apply_id },
      });
    },
    getData() {
      let data = {
        page: this.page,
        per_page: this.per_page,
        type: this.stepId,
      };
      positionDeliver(data)
        .then((res) => {
          if (res.data.code == 1) {
            let arr = res.data.data.data;
            for (let i = 0; i < arr.length; i++) {
              this.orderArr.push(arr[i]);
            }
            setTimeout(() => {
              this.getting = false;
            }, 100);
            this.last_page = res.data.data.last_page;
          } else {
            showToast(res.data.msg);
          }
          this.showCont = true;
        })
        .catch(() => {
          this.showTimeOut = true;
          this.showCont = true;
        });
    },
    nextfn() {
      if (this.$route.path == "/sendBook") {
        let h =
          document.documentElement.scrollHeight || document.body.scrollHeight;
        let wh =
          document.documentElement.clientHeight || document.body.clientHeight;
        let top = document.documentElement.scrollTop || document.body.scrollTop;
        let bottom = h - wh - top;
        if (bottom <= 50) {
          if (this.getting == false) {
            if (this.last_page > this.page) {
              this.getting = true;
              this.page++;
              this.getData();
            }
          }
        }
      }
    },
  },
  mounted() {
    window.addEventListener("scroll", this.nextfn);
  },
  created() {
    this.getData();
  },
};
</script>
<style scoped lang="less">
.container {
  min-height: 100vh;
  background-color: #e7eeff;
  .showCont {
    padding-bottom: 3.75rem;
    box-sizing: border-box;
    padding-top: 1.25rem;
    .orderMain {
      width: 92%;
      margin: 0 auto;
      .orderItem {
        background-color: #fff;
        margin-bottom: 0.75rem;
        padding: 0.75rem;
        border-radius: 0.25rem;
        box-sizing: border-box;
        .itemTime {
          font-size: 0.6rem;
          color: #86a9fb;
          margin-bottom: 0.5rem;
        }
        .itemHead {
          // padding: 0rem 0 0.75rem;
          display: flex;
          align-items: center;
          justify-content: space-between;
          .headName {
            display: flex;
            align-items: center;
            .orderNum {
              font-weight: bold;
              font-size: 0.8rem;
              max-width: 7rem;
              overflow: hidden;
              white-space: nowrap;
              text-overflow: ellipsis;
            }
            .orderTag,
            .quckTag {
              padding: 0.1rem 0.5rem;
              box-sizing: border-box;
              color: #ff5757;
              border: 1px solid #ff5757;
              border-radius: 0.1rem;
              font-size: 0.6rem;
              // margin-left: 0.5rem;
              transform: scale(0.85);
            }
          }
          .headTime {
            color: #999;
            font-size: 0.6rem;
          }
          .headMoney {
            color: #86a9fb;
            font-size: 0.8rem;
          }
        }
        .orderForm {
          margin-top: 0.75rem;
          display: flex;
          justify-content: space-between;
          align-items: center;
          .itemForm {
            flex: 1;
            width: 1rem;
            margin-right: 0.75rem;
          }
          .orderPricr {
            font-size: 1rem;
            color: #86a9fb;
          }
        }
        .formItem {
          display: flex;
          line-height: 1rem;
          margin-bottom: 0.25rem;
          .itemName {
            margin-right: 0.75rem;
            width: 3rem;
          }
          .itemVal {
            color: #666;
            flex: 1;
            width: 1rem;
            word-break: break-all;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2; /* 超出几行省略 */
          }
        }

        .tagCont {
          display: flex;
          align-items: center;
          font-size: 0.6rem;
          margin-top: 0.25rem;
          .tagItem {
            color: #666;
          }
          .userNum_ {
            margin: 0 0.25rem;
          }
        }
        .formUnder {
          width: 100%;
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-top: 0.5rem;
          .userInfo {
            display: flex;
            align-items: center;
            .userImg {
              width: 2rem;
              height: 2rem;
              font-size: 0;
              border-radius: 50%;
              background-color: #86a9fb;
              padding: 0.1rem;
              box-sizing: border-box;
              overflow: hidden;
              margin-right: 0.75rem;
              img {
                width: 100%;
                border-radius: 50%;
              }
            }
            .suerInfoMain {
              display: flex;
              align-items: center;
              .relTag {
                padding: 0.1rem 0.5rem;
                color: #5cc78e;
                border: 1px solid #5cc78e;
                border-radius: 0.1rem;
                transform: scale(0.8);
              }
            }
            .noFlex {
              display: block;
              .userNameBox {
                display: flex;
                align-items: baseline;
              }
              .compDes {
                display: flex;
                align-items: center;
                color: #666;
                font-size: 0.6rem;
                .userNum_ {
                  margin: 0 0.25rem;
                }
              }
            }
            .userName {
              font-size: 0.65rem;
            }
            .userNum {
              display: flex;
              align-items: center;
              font-size: 0.6rem;
              color: #666;
            }
          }
          .subBtn {
            padding: 0.25rem 1rem;
            border: 1px solid #86a9fb;
            color: #86a9fb;
            font-size: 0.6rem;
            border-radius: 0.25rem;
          }
        }
      }
    }
  }
  .backBtn {
    width: 92%;
    background-color: #86a9fb;
    color: #fff;
    text-align: center;
    position: fixed;
    bottom: 0.75rem;
    left: 4%;
    padding: 0.75rem 0;
    font-size: 0.7rem;
    // letter-spacing: 0.25rem;
    border-radius: 0.25rem;
  }
}
</style>
